#!/bin/sh

PATH="%OPTWARE_TARGET_PREFIX%/sbin:%OPTWARE_TARGET_PREFIX%/bin:/sbin:/bin:/usr/sbin:/usr/bin"

[ "`kernelversion`" = 2.4 ] || exit 0 
[ -f /proc/ksyms ] || exit 0
[ -e %OPTWARE_TARGET_PREFIX%/sbin/depmod ] || exit 0

if touch %OPTWARE_TARGET_PREFIX%/lib/modules/$(uname -r)/modules.dep 2>/dev/null; then
	echo -n "Calculating module dependencies... "
	depmod -a -q
	echo "done."
else
	echo "Not calculating module dependencies: %OPTWARE_TARGET_PREFIX%/lib/modules/$(uname -r) is read only."
fi

# Loop over every line in /etc/modules.
echo -n 'Loading modules: '
(cat %OPTWARE_TARGET_PREFIX%/etc/modules; echo) | # make sure there is a LF at the end
while read module args
do
	case "$module" in
		\#*|"") continue ;;
	esac
	echo -n "$module "
	modprobe $module $args
done
echo

exit 0

